package fr.umlv.android.boggle;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class ScoreActivity extends Activity {
	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.score);
        
        //showScore();

    }
    
    
	private void showScore() {
        Resources res = getResources();
        InputStream inputStreamDico = res.openRawResource(R.raw.score);
		InputStreamReader ipsr = new InputStreamReader(inputStreamDico);
		BufferedReader br = new BufferedReader(ipsr);
		String ligne;
		
		TableLayout grid = (TableLayout) findViewById(R.id.scoresTable);
		int i=0;
		try {
			while ((ligne=br.readLine())!=null){
				System.out.println(ligne+"= "+i);
				TextView textView = new TextView(this);
				TableRow row = (TableRow) grid.getChildAt((i/2) * 2);
				if(i%2 == 0) {
					textView.setText(ligne);
					textView.setPadding(3, 3, 3, 3);
					textView.setGravity(Gravity.CENTER);
				}
				else if(i%2 == 1) {
					textView.setText(ligne);
					textView.setPadding(3, 3, 3, 3);
					textView.setGravity(Gravity.RIGHT);
				}

				row.addView(textView);
				i++;
			}
			System.out.println("FILE CLOSE");
			br.close();
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
	
}
